package com.xcf.controller.business.settlement;

import cn.com.xcf.dao.model.TFinFeeCheck;
import cn.com.xcf.dao.model.TFinFeeCheckExample;
import cn.com.xcf.service.FeeCheckService;
import com.xcf.controller.base.BaseController;
import com.xcf.entity.Page;
import com.xcf.util.Jurisdiction;
import com.xcf.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/***
 * 发票签收
 * @author WongBin
 */
@Controller
@RequestMapping(value="/receiptReceive")
public class ReceiptReceiveController extends BaseController {
	
	String menuUrl = "/receiptReceive/index"; //菜单地址(权限用)
    static final String base = "/business/settlement/";

	@Autowired
	private FeeCheckService feeCheckService;

	/**列表
	 * @param page
	 * @throws Exception
	 */
	@RequestMapping(value="/index")
	public ModelAndView list(Page page, HttpServletRequest req) throws Exception{
		Map param = getParams(req);//new PageData(req);
        TFinFeeCheckExample e = new TFinFeeCheckExample();
		e.createCriteria();
		e.setPage(page);
		handlePageParams(param,e.getPage());
        ModelAndView mv = getModelAndView();
        try{
            List<TFinFeeCheck> ret = feeCheckService.selectByPage(e,param,page);
            //PageData pd = getPageData();
            mv.addObject("dataList",ret);
            mv.addObject("pd", page);
            mv.addObject("QX",Jurisdiction.getHC());//按钮权限
            mv.setViewName(base.concat("receipt_receive_index"));
        } catch(Exception ex){
            log.error("query-check-error:"+param,ex);
        }
        return mv;
	}

	/**
	 * save
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/save")
	public ModelAndView save() throws Exception{
		ModelAndView mv = this.getModelAndView();
		PageData pd = new PageData();
		pd = this.getPageData();

		//tFinFeeCheckService.save(pd);
		mv.addObject("msg","success");
		mv.setViewName("save_result");
		return mv;
	}

	/**删除
	 * @throws Exception
	 */
	@RequestMapping(value="/delete")
	public void delete(Object id) throws Exception{

	}

	/**修改
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/edit")
	public ModelAndView edit() throws Exception{

        return null;
	}

	/**去新增页面
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/goAdd")
	public ModelAndView goAdd()throws Exception{
		ModelAndView mv = new ModelAndView();
		/*
		mv.setViewName(PREFIX.concat("/tFinFeeCheck_edit"));
		mv.addObject("msg", "save");
		mv.addObject("pd", pd);*/
		return mv;
	}

	/**去修改页面
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/goEdit")
	public ModelAndView goEdit()throws Exception{
		ModelAndView mv = this.getModelAndView();
		/*pd = tFinFeeCheckService.findById(pd);	//根据ID读取
		mv.setViewName(PREFIX.concat("/tFinFeeCheck_edit"));
		mv.addObject("msg", "edit");
		mv.addObject("pd", pd);*/
		return mv;
	}

	/**
	 * 查看详情
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/detail")
	@ResponseBody
	public Object detail(Object id) throws Exception{
		return null;
	}

}
